<!-- 项目策划任务表 -->
<template>
  <a-card>
    <!-- <title-name title="项目策划任务表" /> -->
    <list-table
      :defaultLoad="false"
      ref="table"
      size="default"
      rowKey="id"
      :columns="columns"
      :request="loadData"
      :alert="true"
      show-size-changer
      show-quick-jumper
      :page-keys="['pageNum', 'pageSize','total']"
      show-pagination="auto"
      :loadPage="{
        currentPage: 'pageNum',
        totalSize: 'total',
        data: 'list'
      }"
    >
      <span slot="serial" slot-scope="text, record, index">{{ index + 1 }}</span>
      <span slot="isKeyProject" slot-scope="text, record, index">{{ handlerisKeyProject(text) }}</span>
      <span slot="status" slot-scope="text, record, index">{{ handlerStatus(text) }}</span>
<!--      <span slot="projectName" slot-scope="text, record, index">-->
<!--        <a-tooltip>-->
<!--          <template slot="title"> {{ text }} </template>-->
<!--          <div class="project-name">{{ text }}</div>-->
<!--        </a-tooltip>-->
<!--      </span>-->
      <span slot="action" slot-scope="text, record">
        <Opera :item="record"></Opera>
      </span>
    </list-table>
  </a-card>
</template>

<script>
import { columns } from '../config'
import Opera from './Opera'
import { getPagePlanTask } from '@/api/projectManagementPlanning/projectPlanningTaskList'
export default {
  name: 'PlanningTaskList',
  props: {
    searchQuery: {
      type: Object,
      default: () => {}
    }
  },
  data() {
    return {
      columns,
      loadData: (p) => {
        const obj = {}
        Object.keys(this.searchQuery).map((key) => {
          if (this.searchQuery[key] !== '') {
            obj[key] = this.searchQuery[key]
          }
        })
        let searchData = Object.assign(p, { param: { ...obj } })
        return getPagePlanTask(searchData).then((res) => {
            return { code: 200, data: res.data.list, ...res.data }
        })
      }
    }
  },

  components: { Opera },

  computed: {},

  created() {},

  mounted() {},

  methods: {
    // 处理是否重点项目的显示
    handlerisKeyProject(val) {
      if (Number(val) === 1) {
        return '是'
      }
      return '否'
    },
    // 处理是否提交的显示
    handlerStatus(val) {
      if (Number(val) === 1) {
        return '已提交'
      }
      return '待提交'
    }
  }
}
</script>
<style lang='less' scoped>
.project-name {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
</style>
